package com.xiaolin.algorithm.nk.two;

import java.util.Scanner;

/**
 * @ClassName Main
 * @Description 根据数字第一位，按从小到大输出（与正负数无关），个位数相同的数字保持先后顺序输出
 * @Detail detail
 * @Author MyPC
 * @Date 2020/12/19
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        // 11,-21,55,21,-22,1
        while (scanner.hasNext()){
            String[] strings = scanner.nextLine().split(",");
            int[] nums=new int[strings.length];
            int[][] bucket=new int[10][100];
            int[] count=new int[10];
            for (String string : strings) {
                int bitNum =string.charAt(string.length()-1)-48;
                bucket[bitNum][count[bitNum]++]=Integer.parseInt(string);
            }
            StringBuilder sb=new StringBuilder();
            for(int i=0;i<count.length;i++){
                if(count[i]>0){
                    for(int j=0;j<count[i];j++){
                        sb.append(bucket[i][j]).append(",");
                    }
                }
            }
            sb.replace(sb.length()-1,sb.length(),"");
            System.out.println(sb);
        }
    }
}
